package com.tianshuo.controller;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName : ControllerErrorAdvice
 * @Description : 用于处理统一的错误
 * @Author : tianshuo
 * @Date: 2020-10-20 16:00
 */
@ControllerAdvice
public class ControllerErrorAdvice {

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public Map errorAdvice(Exception exception) {
        Map map = new HashMap();
        map.put("code", "-1");
        map.put("msg", exception);
        return map;
    }

}

